//
//  MyFavoriteViewController.m
//  SelectionForYou
//
//  Created by qianfeng on 15-6-17.
//  Copyright (c) 2015年 朱共营. All rights reserved.
//

#import "MyFavoriteViewController.h"
#import "MyModel.h"
#import "UIButton+WebCache.h"
#import "DBManager.h"
@interface MyFavoriteViewController ()

@end

@implementation MyFavoriteViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self showUI];
}
- (void)showUI{
    self.view.backgroundColor=[UIColor colorWithRed:226/255.0f green:226/255.0f blue:226/255.0f alpha:1];
    NSArray *arr=[[DBManager sharedManager] readModelsWithRecordType:@"favorites"];
    NSLog(@"%@",arr);
    CGFloat wSpace=([LZXHelper getScreenSize].width-3*57)/4;
    CGFloat hSpace=([LZXHelper getScreenSize].height-64-49-3*57)/4;
    for (int i=0; i<arr.count; i++) {
        MyModel *model=arr[i];
        UIButton *button=[UIButton buttonWithType:UIButtonTypeSystem];
        button.tag=101+i;
        [button sd_setImageWithURL:[NSURL URLWithString:model.headline_img_tb] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed: @"AppIcon76x76~ipad"]  ];
        [button addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [button setFrame:CGRectMake(wSpace+(i%3)*(57+wSpace), hSpace+(i/3)*(hSpace+57), 57,57)];
        [self.view addSubview:button];
    }

}
- (void)btnClick:(UIButton *)btn{
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
